<?php
namespace app\index\controller;

use app\index\model\Information;
use think\Controller;
use think\Db;

class Index extends Controller
{
    public function index()
    {
       return $this->fetch("index/index");
    }

    public function showFunction()
    {
        $account =  $this->request->param("account");
        $name =  $this->request->param("name");
        $identity =  $this->request->param("identity");
        $data = array("account"=>$account, "name"=>$name, "identity"=>$identity);
        $jsons =  json_encode($data);
        $myJson = fopen("json/user.json", "w");
        fwrite($myJson,$jsons);
        fclose($myJson);
//        return $jsons;
        return $this->fetch("index/function");
    }

    public function showStudent()
    {
        return $this->fetch("index/student");
    }

    public function showSuccess()
    {

        return $this->fetch("index/success");
    }

    public function showRest()
    {
        $this->assign("rest",$this->showAllInformation());
        return $this->fetch("index/rest");
    }

    public function showAllInformation(){
        $information = new Information();
        return $information->selectOrFail()->toArray();
    }


}
